<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //  case 1
      var a = 1;
      function f1() {
        console.log(a);
      }

      function f2() {
        var a = 2;

        f1();
      }
      f2();

      // case 2

      var a = 1;

      function f2() {
        var a = 2;

        function f1() {
          console.log(a);
        }
      }
      f2();

      // case 1 和  case2 的区别
    </script>
  </body>
</html>
